fix: return traceTransaction result as a JSON array#28
Open
RaoulSchaffranek wants to merge 2 commits into
Open
fix: return traceTransaction result as a JSON array#28RaoulSchaffranek wants to merge 2 commits into
RaoulSchaffranek wants to merge 2 commits into
Conversation
The traceTransaction RPC put the trace file's contents straight into the result as a String, so the response body carried the trace as a single JSON-encoded string instead of structured data. Clients had to re-parse the JSONL string themselves. Parse the JSONL trace file into a JSON array in #respondTrace, so the result is an array with one object per executed instruction (empty when the transaction ran no instructions; null still means no such trace). The on-disk traces/trace_<hash>.jsonl format is unchanged. Update the trace tests (empty trace is now [] rather than "") and the README / server / node-semantics / architecture docs to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Trace coverage only ever asserted the empty-trace case ([]) and a weak
"len > 0 and every record has an instr key" check on a contract call.
Neither pinned the actual trace content or the record structure.
Add two stronger tests:
- assert foo()'s full instruction trace record-for-record (the exact
trace the README documents), which also guards the array-vs-string
shape of the result;
- invoke a function with arguments (test_integers) and assert every
record is a {pos, instr, stack, locals} object, that stack/locals
entries are [type, value] pairs, that the decoded arguments are bound
as locals 0..3, that intermediate values reach the stack, and that
the body returns Void.
Factor the create-account -> upload -> deploy -> invoke setup, previously
copy-pasted across the trace and args tests, into a _deploy_and_get_invoker
helper, and refactor test_call_tx_with_args onto it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
traceTransactionpreviously returned the raw JSONL file contents as an opaque string; it now parses that JSONL into a proper JSON array (one object per executed WebAssembly instruction), or an empty array when the transaction ran no instructions#parseTraceLinesK function that splits the JSONL text on newlines and parses each non-empty line withString2JSONREADME.md,docs/server.md,docs/architecture.md,docs/node-semantics.md) to reflect the new array shapeempty.wat'sfoo(), the other validates the structure and argument/stack content for a richerargs.watinvocation_deploy_and_get_invokerhelper to eliminate duplicated deploy boilerplate across testsTest plan
test_trace_transaction_retrieves_trace_by_hash— empty array for a no-wasm txtest_trace_transaction_returns_full_instruction_trace_for_foo— exact trace forempty.wattest_trace_records_have_expected_structure_and_reflect_arguments— structure + args/stack coverage forargs.wattest_trace_transaction_unknown_hash_returns_null— null for unknown hashtest_trace_transaction_missing_hash_returns_invalid_params— error for missing param🤖 Generated with Claude Code